<?php

namespace App\Modules\LuckDraw\Models;

use Illuminate\Database\Eloquent\Model;

const DRAW_LOG_FAILED = -1; // 抽奖失败
const DRAW_LOG_SUCCESS = 0; // 抽奖成功奖品待发放
const DRAW_LOG_SENT = 1;  // 抽奖成功奖品已发放

class DrawLogModel extends Model {
    protected $table = "luck_draw_log";

    //status 表示是否已经将奖品发送的用户背包 返回插入的id

    public static function log(int $luckId, int $userId, int $roomId, int $poolId, string $strategy, int $drawNum,  string $awards, int $status, string $desc):int{
        $logModel = new DrawLogModel();
        $logModel->luck_id = $luckId;
        $logModel->user_id = $userId;
        $logModel->room_id = $roomId;
        $logModel->pool = $poolId;
        $logModel->strategy = $strategy;
        $logModel->draw_num = $drawNum;
        $logModel->awards = $awards;
        $logModel->status = $status;
        $logModel->desc = $desc;
        $logModel->save();
        return (int)$logModel->id;
    }

    //失败
    //成功 奖品已发放
    public static function logFailed(){

    }

    //成功 奖品待发放 //
    public static function logSuccess(){

    }
    //成功 奖品已发放
    public static function logSent(){

    }
}